<script>
import { checkLogin } from './api/login';
import { getToken } from './utils/auth';

	export default {   
		onLaunch: function() {
			const token = getToken();
			if (!token){
				uni.reLaunch({
					url:'/pages/login/login'
				});
			}	
		},
		onShow: function(page) {
			//判断是否需要检查
			if (page.path != 'pages/login/login'){
				//调用接口 携带token
				checkLogin()
				.then((res) =>{
					if(res.result === 0){
						uni.setStorageSync('USER',JSON.stringify(res.data.user))
					}else{
						uni.reLaunch({
							url:'/pages/login/login'
						})
					}				
				})
			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	@import url("//at.alicdn.com/t/c/font_4616956_739xpi2pno.css");
	
	:root{
		--color-theme:#FB5231;
		--rounded-sm:4px;
		--rounded:6px;
		--rounded-lg:8px;
		--rounded-xl:10px;
		--rounded-2xl:12px;
        --color-line:#eee;
	}
	
	/*每个页面公共css */
	
	*{
		margin: 0;
		padding:0;
		box-sizing: border-box;
	}
	
	.container{
		width: 100%;
		height: 100vh;
		box-sizing:border-box;
		pading:0;
		margin: 0;
	}
	
    
    .flex{
        display: flex;  
       }
       
       .flex-1{
           flex:1;
       }
       
    .flex-end{
       justify-content: flex-end;
       
    }
	
	

</style>
